package com.ap.core.dao.impl;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import com.ap.core.dao.AbstractReadOnlyAPCoreBaseJpaDao;
import com.ap.core.dao.ZappConsumerUserDao;

import com.ap.core.domain.ZappConsumerUser;

/**
 * The Class JpaZappConsumerUserDao.
 */
public class JpaZappConsumerUserDao extends
		AbstractReadOnlyAPCoreBaseJpaDao<ZappConsumerUser, Long> implements
		ZappConsumerUserDao {

	/* (non-Javadoc)
	 * @see com.ap.core.dao.ReadOnlyGenericDao#findById(java.lang.Object)
	 */
	@Override
	public ZappConsumerUser findById(Long primaryKey) {
		return findById(ZappConsumerUser.class, primaryKey);
	}

	/* (non-Javadoc)
	 * @see com.ap.core.dao.ZappConsumerUserDao#getZappConsumerUserByFiIdentificationAndFiCustomerId(java.lang.String, java.lang.String)
	 */
	@Override
	public ZappConsumerUser getZappConsumerUserByFiIdentificationAndFiCustomerId(String fiIdentification,
			String fiCustomerId) {
		Criteria criteria = getSession().createCriteria(ZappConsumerUser.class);
		criteria.add(Restrictions.eq("fiIdentification", fiIdentification));
		criteria.add(Restrictions.eq("fiCustomerId", fiCustomerId));
		return (ZappConsumerUser) criteria.uniqueResult();
	}
	
	/* (non-Javadoc)
	 * @see com.ap.core.dao.ZappConsumerUserDao#getZappConsumerUserByFiIdentificationAndZappCustomerId(java.lang.String, java.lang.Long)
	 */
	@Override
	public ZappConsumerUser getZappConsumerUserByFiIdentificationAndZappCustomerId(String fiIdentification,Long zappComsumerId){
		Criteria criteria = getSession().createCriteria(ZappConsumerUser.class);
		criteria.add(Restrictions.eq("fiIdentification", fiIdentification));
		criteria.add(Restrictions.eq("zappConsumerId", zappComsumerId));
		return (ZappConsumerUser) criteria.uniqueResult();
	}

    /* (non-Javadoc)
     * @see com.ap.core.dao.ZappConsumerUserDao#getZappConsumerUserByEmailIdAndFiId(java.lang.String, java.lang.String)
     */
    @Override
    public ZappConsumerUser getZappConsumerUserByEmailIdAndFiId(String zappEmailId, String fiIdentification) {
        Criteria criteria = getSession().createCriteria(ZappConsumerUser.class);
        criteria.add(Restrictions.eq("zappEmailId", zappEmailId));
        criteria.add(Restrictions.eq("fiIdentification", fiIdentification));
        return (ZappConsumerUser)criteria.uniqueResult();
    }
}
